import router from '@system.router';
import prompt from '@system.prompt';
import IndexApi from '../../api/indexApi.js'
import ClassApi from '../../api/classApi.js'
import CourseApi from '../../api/courseApi.js'
import HttpUtil from '../../utils/httpUtil.js'

export default {
    data: {
        baseImageUrl: '',
        swiperImages: ['swiper1.jpg', 'swiper2.jpg', 'swiper3.jpg', 'swiper4.jpg', 'swiper5.jpg'],
        quickStart: [{
                         name: '课程',
                         icon: 'common/icon/course-icon.png',
                         url: 'pages/courses/courses'
                     }, {
                         name: '班级',
                         icon: 'common/icon/class-icon.png',
                         url: 'pages/classes/classes'
                     }, {
                         name: '测评',
                         icon: 'common/icon/test-icon.png',
                         url: 'pages/evaluations/evaluations'
                     }, {
                         name: '培训',
                         icon: 'common/icon/train-icon.png',
                         url: 'pages/trains/trains'
                     }, {
                         name: '群组',
                         icon: 'common/icon/group-icon.png',
                         url: 'pages/groups/groups'
                     }],
        classes: [],
        courses: [],
    },
    onInit() {
        //            window.getTopWindow((err, data) => {
        //                data.setFullScreen(true, null);
        //            });
        this.baseImageUrl = this.$app.$def.globalData.baseImageUrl;

        // this.base_image_url = 'common/temp/';
        // 初始化热门班级
        IndexApi.getHotClasses((data) => {
            this.classes = data;
        });
        // 初始化热门课程
        IndexApi.getHotCourses((data) => {
            this.courses = data;
        });
    },
    queryClass(id) {
        ClassApi.getClass(id, (data) => {
            router.push({
                uri: 'pages/classDetail/classDetail',
                params: {
                    id, data
                }
            })
        });
    },
    queryCourse(id) {
        CourseApi.getCourse(id, (data) => {
            router.push({
                uri: 'pages/courseDetail/courseDetail',
                params: {
                    id, data
                }
            })
        });
    },
    forward(uri) {
        router.push({
            uri
        })
    }
}
